import logging
from pathlib import Path
import time

DEBUG_MODE = True

MAX_REDIRECTS = 3

DATA_PATH = Path("/data")
MUSIC_PATH = Path("/music")


# 获取时间戳
def get_timestamp():
    return int(time.time() * 1000)


# 配置日志
LOG_FILE = DATA_PATH / "debug.log"  # 日志文件路径
logging.basicConfig(
    level=logging.DEBUG,
    format="%(asctime)s [%(levelname)s] %(message)s",
    handlers=[
        logging.FileHandler(LOG_FILE),
        logging.StreamHandler(),  # 同时输出到控制台
    ],
)


# 自定义日志函数
def log(message: str, level: str = "INFO"):
    """
    在 DEBUG_MODE 下记录日志信息。

    :param message: 日志内容
    :param level: 日志级别（INFO, WARNING, ERROR）
    """
    if DEBUG_MODE:
        if level.upper() == "INFO":
            logging.info(message)
        elif level.upper() == "WARNING":
            logging.warning(message)
        elif level.upper() == "ERROR":
            logging.error(message)
        else:
            logging.info(message)  # 默认使用 INFO 级别
